import { Dropdown } from 'antd';
import { history } from '@umijs/max';

const Avator = ({ src, alt, size = 30 }) => {
  const items = [
    {
      key: '1',
      label: '个人中心',
    },
    {
      type: 'divider',
    },
    {
      key: '2',
      label: (
        <a
          onClick={() => {
            history.push('/login');
          }}
        >
          退出登录
        </a>
      ),
    },
  ];
  return (
    <Dropdown
      menu={{
        items,
      }}
      trigger={['click']}
    >
      <a onClick={(e) => e.preventDefault()}>
        <img
          src={
            src ??
            'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png'
          }
          alt={alt}
          width={size}
          height={size}
        />
      </a>
    </Dropdown>
  );
};

export default Avator;
